// pinia 用户使用方法
import { defineStore } from "pinia";
export const userStore = defineStore({
    id: 'user',
    // 数据
    state:()=>{
        return{
            token: localStorage.getItem('token') || '',
            // userInfo:{}
            userInfo: localStorage.getItem('userInfo') || {},
        }
    },
    // 方法
    actions:{
        setUserInfo(data: any){
            this.token = data.token,
            this.userInfo = data.user_info
            localStorage.setItem('token', this.token)
            // 存入前转换成字符串 JSON.stringify(this.userInfo)
            localStorage.setItem('userInfo', JSON.stringify(this.userInfo))
        }
    }
})